/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package db;

import java.sql.*;
import bean.*;

public class DAOTest {

    public static Connection getConnection()
    {
        return getConnection("CSSADEV");
    }

    public static Connection getConnection(String server)
    {
        DBConn db = new DBConn(server);
        return db.getConnection();
    }

    public static boolean activityExists(ActivityBean aBean)
    {
        Connection con = getConnection();
        boolean result = false;

        try {
            Statement stmt = con.createStatement();
            String select = "SELECT * FROM dbo.COMSERV_ACTIVITY WHERE activityid = " + aBean.getId();
            ResultSet rs = stmt.executeQuery(select);
            //if record returned, rs.next is true
            result = rs.next();
            //close
            stmt.close();
            con.close();
        }
        catch (SQLException e) {System.err.println(e.getMessage());}
        catch (Exception e) {System.err.println(e.getMessage());}
        return result;
    }
}
